package
        com.chb.controller;

import com.chb.annotation.LogAnnotation;
import com.chb.model.entity.Role;
import com.chb.model.vo.PageBean;
import com.chb.model.vo.Result;
import com.chb.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author：xIAO_ZHOU_TX
 * @date：Created in 2023/9/26 15:17
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService roleService;

    //分页查所有
    @PostMapping
    public PageBean<Role> list(Integer currentPage, Integer pageSize) {
        PageBean<Role> allRoleInfo = roleService.findAllRoleInfo(currentPage, pageSize);
        return allRoleInfo;
    }

    //添加角色
    @PostMapping("/insert")
    @LogAnnotation(business_type="添加角色")
    public Integer insertRole(@RequestBody Role role) {
        Integer integer = roleService.insertRole(role);
        return integer;

    }

    //    删除角色
    @PostMapping("/delete")
    @LogAnnotation(business_type = "删除角色")
    public Integer deleteRole(@RequestBody Role role) {
        Integer integer = roleService.deleteRole(role);
        return integer;

    }

    //    修改角色
    @PostMapping("/update")
    @LogAnnotation(business_type = "修改员工信息")
    public Integer UpdateRole(@RequestBody Role role) {
        Integer integer = roleService.updateRole(role);
        return integer;

    }

    //获取所有的职位
    @RequestMapping("/selectAllRole")
    public Result selectAllRole() {
        Result rolename = roleService.findRolename();
        return rolename;
    }

}